import 'package:boss/models/store_table.dart';
import 'package:json_annotation/json_annotation.dart';

part 'necessary_order.g.dart';

@JsonSerializable(explicitToJson: true)
class NecessaryOrder extends Object {
  int necessaryId;

  int storeId;

  String necessaryName;

  int chargingMode;

  int everyoneCount;

  int useRange;

  int useStatus;

  int deleted;

  int commodityId;

  int menuId;

  String menuName;

  int categoryId;

  String categoryName;

  String title;

  String subTitle;

  String images;

  int lowestPrice;

  int skuNum;

  int price;

  int memberPrice;

  int stock;

  int onsale;

  int status;

  String commodityCellTime;

  String commodityCellWeek;

  String commodityCellDate;

  int commodityMinPie;

  int commodityChefPrint;

  String commodityCode;

  String commodityBarCode;

  String description;

  int deviceId;

  int commodityDiscountType;

  String unit;

  int commodityType;

  @JsonKey(defaultValue: [])
  List<StoreTable> useTableList;

  NecessaryOrder(
    this.necessaryId,
    this.storeId,
    this.necessaryName,
    this.chargingMode,
    this.everyoneCount,
    this.useRange,
    this.useStatus,
    this.deleted,
    this.commodityId,
    this.menuId,
    this.menuName,
    this.categoryId,
    this.categoryName,
    this.title,
    this.subTitle,
    this.images,
    this.lowestPrice,
    this.skuNum,
    this.price,
    this.memberPrice,
    this.stock,
    this.onsale,
    this.status,
    this.commodityCellTime,
    this.commodityCellWeek,
    this.commodityCellDate,
    this.commodityMinPie,
    this.commodityChefPrint,
    this.commodityCode,
    this.commodityBarCode,
    this.description,
    this.deviceId,
    this.commodityDiscountType,
    this.unit,
    this.commodityType,
  );

  factory NecessaryOrder.fromJson(Map<String, dynamic> srcJson) => _$NecessaryOrderFromJson(srcJson);

  Map<String, dynamic> toJson() => _$NecessaryOrderToJson(this);

  bool get isUseStatus {
    return useStatus == 0;
  }

  String get chargingModeString {
    Map<int, String> _map = {
      0: '人',
      1: '桌',
    };

    return _map[chargingMode];
  }

  static const Map<String, int> useRangeMap = {
    '全部': 0,
    '扫码点餐': 1,
    '收银机点餐': 3,
  };
}
